home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The Best of MacTutor - S…e Code for Volumes 1 to 5
/
The Best of MacTutor - Source Code for Volume 1-5 (Wayzata Technology)(6031)(1990).bin
/
Source Code
/
#49 (Oct 89)
/
DMP Source
/
src
/
MPWGlue.a
< prev
next >
Wrap
Text File
|
1989-01-02
|
5KB
|
206 lines
;;
;; Glue for Printer Driver code resource headers using MPW C.
;; The header for each type of resource is placed in a separate
;; module using the Asm PROC directive. The "-m" option to the
;; linker makes it the entry point to the linked code resource.
;;
;; Earle R. Horton. All rights reserved.
;; Tuesday, December 13, 1988
;;
;; Some of the Glue routines contain data. This is read-only!
;;
CASE ON
SEG 'Main'
INCLUDE 'SysEqu.a'
myDrvrFlags EQU ((1<<dCtlEnable) + (1<<dStatEnable) + (1<<dNeedGoodBye)) << 8 ; Flag byte.
;;
;; The header for the 'DRVR' resource.
;;
DriverEntry PROC EXPORT ;; 'DRVR' starts here.
IMPORT myPrOpen ; open routine
IMPORT myPrPrime ; prime
IMPORT myPrControl ; control
IMPORT myPrStatus ; status
IMPORT myPrClose ; close
CODE
DC.W myDrvrFlags ; control and status enable only
DC.W 0 ; doesn't need time
DC.W 0 ; no events
DC.W 0 ; no menu
DC.W myPrOpenCall-DriverEntry ; Offsets to driver routines.
DC.W myPrPrimeCall-DriverEntry
DC.W myPrControlCall-DriverEntry
DC.W myPrStatusCall-DriverEntry
DC.W myPrCloseCall-DriverEntry
STRING PASCAL
DC.B '.Print' ; Driver name as Pascal string
DC.W 0 ; Zero for word-align.
dummyheader ; Make it look like a procedure for
LINK A6,#0 ; MacsBug
myPrOpenCall
PEA myPrOpen ;; SP -> desired driver routine.
BRA.S CallDriver ;; Jump to interface to call real routine.
myPrPrimeCall
PEA myPrPrime ;; Times 5.
BRA.S CallDriver
myPrControlCall
PEA myPrControl
BRA.S CallDriver
myPrStatusCall
PEA myPrStatus
BRA.S CallDriver
myPrCloseCall
PEA myPrClose
CallDriver
MOVE.L A1,-(SP) ;; Push pointer to device control entry.
MOVE.L A0,-(SP) ;; Push pointer to parameter block.
MOVEA.L 8(SP),A0 ;; Get routine address.
JSR (A0) ;; Call driver routine.
;; Result is in D0.
MOVE.L (SP)+,A0 ;; Restore registers.
MOVE.L (SP)+,A1 ;; Note: C programs leave the stack alone.
ADDQ.W #$4,A7 ;; Fix up stack pointer.
BTST #$01,$0006(A0) ;; Immediate call?
BNE.S StdReturn ;; Yes, regular return.
MOVE.L JIODone,-(sp) ;; No, return via IODone
StdReturn
RTS
label ;; This is for MacsBug.
UNLK A6
RTS
STRING ASIS
DC.B 'DMP-110 '
ENDP
;;
;; The header for the Chooser Device Package.
;;
CASE OFF
PackEntry PROC EXPORT
IMPORT device
BRA.S devicejump
deviceID
DC.W 0
Packname
DC.L $5041434B ; 'PACK'
IDnumber
DC.W $F000 ; -4096
Version
DC.W 1
Flags
DC.L $0C00E000
devicejump
JMP device
ENDP
;;
;; The header for the Job and Style Dialogs code.
;;
CASE OFF
DialogsEntry PROC EXPORT
import MyPrintDefault
import MyPrStlDialog
import MyPrJobDialog
import MyPrStlInit
import MyPrJobInit
import MyPrDlgMain
import MyPrValidate
import MyPrJobMerge
bra.w MyPrintDefault
bra.w MyPrStlDialog
bra.w MyPrJobDialog
bra.w MyPrStlInit
bra.w MyPrJobInit
bra.w MyPrDlgMain
bra.w MyPrValidate
bra.w MyPrJobMerge
ENDP
;;
;; Routines to call Pascal procedures which are known by address
;; and not by name. (ProcPtr glue).
;;
CASE OFF
CallDlgInit PROC EXPORT
Export CallItemProc
CallItemProc
MOVE.L (SP)+,A0 ; Pop return address.
MOVE.l (SP)+,A1 ; Pop actual function address.
MOVE.L A0,-(SP) ; Push return address.
JMP (A1) ; Call the Pascal Function
ENDP
;;
;; The header for the printing code.
;;
CASE OFF ; If main code is in Pascal.
PrintEntry PROC EXPORT
IMPORT myPrOpenDoc
IMPORT myPrCloseDoc
IMPORT myPrOpenPage
IMPORT myPrClosePage
bra.w myPrOpenDoc
bra.w myPrCloseDoc
bra.w myPrOpenPage
bra.w myPrClosePage
ENDP
CASE ON
serialdata PROC EXPORT
;
; This module consists of read-only data.
;
baud300 EQU 380
baud600 EQU 189
baud1200 EQU 94
baud1800 EQU 62
baud2400 EQU 46
baud3600 EQU 30
baud4800 EQU 22
baud7200 EQU 14
baud9600 EQU 10
baud19200 EQU 4
baud57600 EQU 0
EXPORT AOutName,BOutName,BaudRates,prhireslf
;
; Handy storage place for constant strings and data which can be copied
; by the Driver routines.
;
STRING PASCAL
AOutName
DC.B '.AOut'
BOutName
DC.B '.BOut'
STRING ASIS
prhireslf
dc.b 3,26,27,'G'
ALIGN 2
BaudRates
DC.W baud300
DC.W baud600
DC.W baud1200
DC.W baud1800
DC.W baud2400
DC.W baud3600
DC.W baud4800
DC.W baud7200
DC.W baud9600
DC.W baud19200
DC.W baud57600
ENDP
END